package com.ruoyi.wcf.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wcf.domain.WcfMobileBrand;
import com.ruoyi.wcf.service.IWcfMobileBrandService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 手机品牌Controller
 *
 * @author WZP
 * @date 2022-04-02
 */
@RestController
@RequestMapping("/wcf/WcfMobileBrand")
public class WcfMobileBrandController extends BaseController
{
    @Autowired
    private IWcfMobileBrandService wcfMobileBrandService;

    /**
     * 查询手机品牌列表
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfMobileBrand:list')")
    @GetMapping("/list")
    public TableDataInfo list(WcfMobileBrand wcfMobileBrand)
    {
        startPage();
        List<WcfMobileBrand> list = wcfMobileBrandService.selectWcfMobileBrandList(wcfMobileBrand);
        return getDataTable(list);
    }

    /**
     * 导出手机品牌列表
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfMobileBrand:export')")
    @Log(title = "手机品牌", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WcfMobileBrand wcfMobileBrand)
    {
        List<WcfMobileBrand> list = wcfMobileBrandService.selectWcfMobileBrandList(wcfMobileBrand);
        ExcelUtil<WcfMobileBrand> util = new ExcelUtil<WcfMobileBrand>(WcfMobileBrand.class);
        return util.exportExcel(list, "手机品牌数据");
    }

    /**
     * 获取手机品牌详细信息
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfMobileBrand:query')")
    @GetMapping(value = "/{brandId}")
    public AjaxResult getInfo(@PathVariable("brandId") Long brandId)
    {
        return AjaxResult.success(wcfMobileBrandService.selectWcfMobileBrandByBrandId(brandId));
    }

    /**
     * 新增手机品牌
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfMobileBrand:add')")
    @Log(title = "手机品牌", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WcfMobileBrand wcfMobileBrand)
    {
        return toAjax(wcfMobileBrandService.insertWcfMobileBrand(wcfMobileBrand));
    }

    /**
     * 修改手机品牌
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfMobileBrand:edit')")
    @Log(title = "手机品牌", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WcfMobileBrand wcfMobileBrand)
    {
        return toAjax(wcfMobileBrandService.updateWcfMobileBrand(wcfMobileBrand));
    }

    /**
     * 删除手机品牌
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfMobileBrand:remove')")
    @Log(title = "手机品牌", businessType = BusinessType.DELETE)
	@DeleteMapping("/{brandIds}")
    public AjaxResult remove(@PathVariable Long[] brandIds)
    {
        return toAjax(wcfMobileBrandService.deleteWcfMobileBrandByBrandIds(brandIds));
    }

    /**
     * 查询手机品牌列表-下拉框
     */
    @GetMapping("/getList")
    public AjaxResult getList() {
        return AjaxResult.success(wcfMobileBrandService.getList());
    }
}
